WScript.Echo("This script will wipe ALL TRACKS from the library and remove ALL FILES from your drive. You sure?");

var ITTrackKindFile	= 1;
var	iTunesApp = WScript.CreateObject("iTunes.Application");
var	deletedTracks = 0;
var	mainLibrary = iTunesApp.LibraryPlaylist;
var	tracks = mainLibrary.Tracks;
var	numTracks = tracks.Count;
var	i;

while (numTracks != 0)
{
	var	currTrack = tracks.Item(numTracks);
	
	// is this a file track?
	if (currTrack.Kind == ITTrackKindFile)
	{
		// yes, does it have an empty location?
		if (currTrack.Location == "")
		{
			// yes, delete it
			currTrack.Delete();
			deletedTracks++;
		} else {
			var fso = new ActiveXObject("Scripting.FileSystemObject");
	        	fso.DeleteFile(currTrack.Location);
	        	currTrack.Delete();
	        	deletedTracks++;	
	        }
	}
	
	numTracks--;
}

if (deletedTracks > 0)
{
	WScript.Echo("Removed " + deletedTracks + " tracks and audio files.");
}
else
{
	WScript.Echo("No dead tracks were found.");
}
